#include <iostream>
#include <vector>

// 选择排序：升序
void selectionSort(std::vector<int>& v) {
    const size_t n = v.size();
    for (size_t i = 0; i < n; ++i) {
        size_t minIdx = i;
        for (size_t j = i + 1; j < n; ++j) {
            if (v[j] < v[minIdx]) minIdx = j;
        }
        std::swap(v[i], v[minIdx]);
    }
}


int main() {
    std::vector<int> data{42, 7, 13, 5, 99, 3};

    std::cout << "Before sort: ";
    for (int x : data) std::cout << x << ' ';
    std::cout << '\n';

    selectionSort(data);

    std::cout << "After  sort: ";
    for (int x : data) std::cout << x << ' ';
    std::cout << '\n';
    return 0;
}